package com.sdap2.common.exception;
import com.sdap2.common.model.ApiResult;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHanderAdvice {
    //TODO: implement global exception handling
    @ExceptionHandler({Exception.class})
    public ApiResult handleException(Exception e) {
        //TODO: handle exception and return a RespondMessage object
        e.printStackTrace();
        return  ApiResult.error(StringUtils.hasLength(e.getMessage())?e.getMessage(): "操作失败");

    }
}
